﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wfCustCart.aspx.cs" Inherits="msBsc.WebUi.wfCustCart" %>

<!DOCTYPE HTML>
<html>
<head id="Head1" runat="server"> 
    <title>客户购物车管理</title> 
    <link rel="shortcut icon" href="/themes/Style1/Image/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/??themes/Style1/StyleQt.css,themes/Style1/cart.css" />
    <script src="/??jqPlugin/js/jquery-1.8.3.min.js,js/jBase.js,js/jBPage.js,themes/Style1/jsQt.js,jqPlugin/js/laytpl.js"
        type="text/javascript"></script>
    <!--head fix rgn-->
    <script type="text/javascript">
        $(window).load(function () {
            $.ploadFile("layer", function (script, textStatus) {
            });

            $("#J_CartSwitch li").hover(function () {
                $("#J_FilterBar .floater").animate({ left: 134 * ($(this).index()) + 'px' }, 100);
            }, function () {
            })
            .click(function () {
                $("#J_CartSwitch .current").removeClass("current");
                $(this).addClass("current");

                //                    doToPageNm();
            });
            $("#J_CartSwitch").hover(function () { }, function () {
                $("#J_FilterBar .floater").animate({ left: 134 * ($("#J_CartSwitch .current").index()) + 'px' }, 100);
            });


            $("#J_SelectAllCbx1").click(function () {
                $("#J_OrderList .J_CheckBoxShop,#J_OrderList .J_CheckBoxItem").attr("checked", $(this).attr("checked") == true || $(this).attr("checked") == "checked");
                staticAmt();
            });
            $("#J_SelectAll2").click(function () {
                $("#J_OrderList .J_CheckBoxShop,#J_OrderList .J_CheckBoxItem").attr("checked", true);
                staticAmt();
            });


            $("#J_OrderList .J_CheckBoxShop").live('click', function () {
                $(this).parent().parent().parent().find(".item-list .J_CheckBoxItem").attr("checked", $(this).attr("checked") == true || $(this).attr("checked") == "checked");
                staticAmt();
            });

            $(".J_CheckBoxItem").live('click', function () {
                staticAmt();
            });

            $(".J_Del").live('click', function () {
                var _oidtm = $(this).attr("order-id");
                changeQty(_oidtm, '', true);
            });

            $(".J_DeleteSelected").live('click', function () {
                changeQty(getselId(), '', true);
            });

//            $(".J_ItemAmount").live("change", function () {
//                var _qtytem = parseInt($(this).val());
//                var _qtymaxtem = parseInt($(this).attr('data-max'));
//                if (_qtytem + 1 <= _qtymaxtem) {
//                    $(this).val(_qtytem + 1);
//                    var _oidtm = $(this).parent().parent().parent().parent().parent().find(".J_CheckBoxItem").attr("order-id");
//                    changeQty(_oidtm, 1);
//                } else {
//                    alert("已超出库存！");
//                }
//            });

            $(".J_Minus").live('click', function () {
                var _qtytem = parseInt($(this).next().val());
                if (_qtytem > 1) {
                    $(this).next().val(_qtytem - 1);
                    var _oidtm = $(this).parent().parent().parent().parent().parent().find(".J_CheckBoxItem").attr("order-id");
                    changeQty(_oidtm, -1);
                }
            });

            $(".J_Plus").live('click', function () {
                var _qtytem = parseInt($(this).prev().val());
                var _qtymaxtem = parseInt($(this).prev().attr('data-max'));
                if (_qtytem + 1 <= _qtymaxtem) {
                    $(this).prev().val(_qtytem + 1);
                    var _oidtm = $(this).parent().parent().parent().parent().parent().find(".J_CheckBoxItem").attr("order-id");
                    changeQty(_oidtm, 1);
                } else {
                    alert("已超出库存！");
                }
            });
            $(".J_ClearInvalid").live('click', function () {
                doClearInvalid();
            });


            $("#J_Go,#J_SmallSubmit").click(function () {
                var _oid = getselId();
                if (_oid) {
                    window.location.href = "/c_CustOrder.htm?s=1&b=" + _oid;
                } else {
                    alert("请先选择记录！");
                }
            });


            $(window).bind('resize', function () { setJ_FloatBar(); })
        .bind('scroll', function () { setJ_FloatBar(); });
            setJ_FloatBar();
        });

        function doClearInvalid() {
            var loadi = layer.load('正在清除中…');
            try {
                function closeload() { layer.close(loadi); }
                var _jsParam = new jsonRow();
                _jsParam.AddCell("ACTION", "doClearInvalid");
                _jsParam.AddCell("SEL_ID", getselId()); 

                ajaxComm(_jsParam, null, closeload);
            }
            catch (err) {
                layer.close(loadi);
            }
        };

        function getselId() {
            var selid = '';
            $(".J_CheckBoxItem").each(function (_key, _val) {
                if ($(this).attr("checked") == true || $(this).attr("checked") == "checked") {
                    selid += selid == '' ? $(this).attr("order-id") : ',' + $(this).attr("order-id");
                }
            });
            return selid;
        };

        function staticAmt() {
            var _chkAmt = 0;
            var _chkQty = 0;
            $(".J_CheckBoxItem").each(function (_key, _val) {
                var $itemtem = $(this).parent().parent().parent().parent().parent();
                if ($(this).attr("checked") == true || $(this).attr("checked") == "checked") {
                    $itemtem.removeClass("item-selected").addClass("item-selected");
                    _chkAmt +=parseFloat( $itemtem.find(".J_ItemSum").html());
                    _chkQty++;
                } else {
                    $itemtem.removeClass("item-selected");
                }
            });

            $("#J_SmallTotal").html(_chkAmt.toFixed(2));
            $("#J_Total").html(_chkAmt);
            $("#J_SelectedItemsCount").html(_chkQty);
            if (_chkQty > 0) {
                $("#J_Go").removeClass("submit-btn-disabled");
                $("#J_SmallSubmit").removeClass("submit-btn-disabled");
            } else {
                $("#J_Go").removeClass("submit-btn-disabled").addClass("submit-btn-disabled");
                $("#J_SmallSubmit").removeClass("submit-btn-disabled").addClass("submit-btn-disabled");
            }
        };

        function setJ_FloatBar() {

            if ($(document).scrollTop() + $(window).height() < $("#J_FloatBarHolder").offset().top) {
                $("#J_FloatBar").css('z-index', '99999').css('position', 'fixed').animate({ bottom: 0, left: $("#J_FilterBar").offset().left, width: $("#J_FilterBar").width() }, 200);
            } else {
                $("#J_FloatBar").css('z-index', '99999').css('position', 'static');
            }
        };
//        selected item-selected
        function updateTableHtml(_data) {
            var tpl = HtmlUtil.htmlDecode(document.getElementById('cart_list_temp').innerHTML);
            laytpl(tpl).render(_data, function (render) {
                $("#J_OrderList").empty().html(render);
            });
        };

        function changeQty( sOId, sQty,bldelall) { 
            if (!sOId) { return; }
            sQty = sQty || '';
            jQuery.loginCallBack(function () {
                jQuery.loadHtml('/pgajax.axd?DELCART_DATA=1' + '&b=' + sOId + '&q=' + sQty).done(function (_retstr) {
                    if (bldelall) {
                        window.location.reload(true); 
                    }
                    var $itemtem1 = $(".J_CheckBoxItem[order-id='" + sOId + "']");
                    if ($itemtem1.length > 0) {
                        var $itemtem = $itemtem1.parent().parent().parent().parent().parent().parent();
                        var $itempartem = $itemtem.parent().parent().parent().parent().parent();

                        var arrqty = _retstr.split(',');
                        var _retqty1 = 0;
                        var _retqty2 = 0;
                        if (arrqty && arrqty.length > 0) {
                            _retqty1 = parseInt(arrqty[0]);
                            _retqty2 = parseInt(arrqty[1]);
                        }
                        if (_retqty1 == 0) {
                            $itemtem.remove();
                            if ($itempartem.find(".goods-item").length <= 0) {
                                $itempartem.remove();
                            }
                        } else {
                            $itemtem.find(".J_ItemAmount").html(_retqty1);
                            $itemtem.find(".J_ItemSum").html((_retqty1 * parseFloat($itemtem.find(".J_Price").html())).toFixed(2));
                        }
                        $(".cart-sum-txt").html(_retqty2);
                        staticAmt();
                    }
                });
            }, true);
        };
    </script> 
</head>
<body>
    <div id="mallPage" class="tms-page mallAct tmall-  page-not-market">
        <!-- -->
        <!--商城通用顶通-->
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderTopHtml()%>
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetHeaderLogoHtml("会员中心")%> 
        <div style="clear:both;height:5px;"></div>
            <div id="content" class="content" style="width:1190px; margin:auto;">
        <div class="page lang-zh-S"> 



 <div id="mytaobao-panel" class="grid-c2">
 <div class="col-main" id="J_Col_Main" style="padding-bottom: 0;">
 <div class="bought">



<div class="main-wrap">
 <input id="J_ShareParam" type="hidden" value="{&quot;client_id&quot;:&quot;004&quot;}">
 <span class="mytaobao-rc-tp"><span></span></span>

 <div id="main-content">
  


 <div id="J_Cart" class="cart">
     <div id="J_FilterBar" class="cart-filter-bar">
         <ul id="J_CartSwitch" class="switch-cart">
             <li class="btn-switch-cart switch-cart-0 current"><a href="/c_CustCart.htm?s="
                 class="J_MakePoint" ><em>全部商品</em><span class="number" id="emD1">0</span><span
                     class="pipe"></span></a></li>
                     <li class="btn-switch-cart switch-cart-2 "><a
                         href="/c_CustCart.htm?s=0" class="J_MakePoint" ><em>降价商品</em><span
                             class="number" id="emD2">0</span><span class="pipe"></span></a></li>
                             <li class="btn-switch-cart switch-cart-4 ">
                                 <a href="/c_CustCart.htm?s=1" class="J_MakePoint" ><em>库存紧张</em><span
                                     class="number" id="emD3">0</span><span class="pipe"></span></a></li>
                                     </ul>
         <div class="cart-sum">
             已选商品(不含运费)：<strong class="price">￥<em id="J_SmallTotal">0.00</em></strong><a id="J_SmallSubmit" class="submit-btn submit-btn-disabled"
                 >结&nbsp;算</a></div>
         <div class="wrap-line">
             <div class="floater" style="width: 134px; left: 0px;">
             </div>
         </div>
     </div>


     <div id="J_CartMain" class="cart-main">
         <div class="cart-table-th">
             <div class="wp">
                 <div class="th th-chk" >
                     <div class="td-inner">
                             <input class="J_CheckBoxShopf" id="J_SelectAllCbx1" type="checkbox" name="select-all" 
                                 /><label for="J_SelectAllCbx1" title="勾选购物车内所有商品">全选</label></div> 
                 </div>
                 <div class="th th-item">
                     <div class="td-inner">
                         商品信息</div>
                 </div>
                 <div class="th th-info">
                     <div class="td-inner">
                         &nbsp;</div>
                 </div>
                 <div class="th th-price">
                     <div class="td-inner">
                         单价（元）</div>
                 </div>
                 <div class="th th-amount">
                     <div class="td-inner">
                         数量</div>
                 </div>
                 <div class="th th-sum">
                     <div class="td-inner">
                         金额（元）</div>
                 </div>
                 <div class="th th-op">
                     <div class="td-inner">
                         操作</div>
                 </div>
             </div>
         </div>
         <div id="J_OrderList"  style=" background-color:#ffffff;">
          </div>
         </div>

     <div id="J_FloatBarHolder" class="float-bar-holder">
         <div id="J_FloatBar" class="float-bar clearfix has-items default" style="position: static;">
             <div id="J_SelectedItems" class="group-wrapper group-popup hidden" style="display: none;">
                 <div id="J_SelectedItemsList" class="group-content">
                 </div>
                 <span class="arrow" style="left: 650px;"></span>
             </div>
             <div class="float-bar-wrapper">
                 <div id="J_SelectAll2" class="select-all J_SelectAll">
                     <div class="cart-checkbox">
                         <input class="J_CheckBoxShop" id="J_SelectAllCbx2" type="checkbox" name="select-all"
                             ><label for="J_SelectAllCbx2">勾选购物车内所有商品</label></div>
                     &nbsp;全选</div>
                 <div class="operations">
                     <a href="#" hidefocus="true" class="J_DeleteSelected">删除</a><a href="javascript:void(0);" hidefocus="true"
                         class="J_ClearInvalid hidden" style="display: inline;">清除失效宝贝</a></div>
                 <div class="float-bar-right">
                     <div id="J_ShowSelectedItems" class="amount-sum">
                         <span class="txt">已选商品</span><em id="J_SelectedItemsCount">0</em><span class="txt">件</span><div
                             class="arrow-box">
                             <span class="selected-items-arrow"></span><span class="arrow"></span>
                         </div>
                     </div>
                     <div id="J_CheckCOD" class="check-cod" style="display: none;">
                         <span class="icon-cod"></span><span class="s-checkbox J_CheckCOD"></span>货到付款</div>
                     <div class="pipe">
                     </div>
                     <div class="price-sum">
                         <span class="txt">合计(不含运费)：</span><strong class="price">￥<em id="J_Total">0.00</em></strong></div>
                     <div class="btn-area">
                         <a href="javascript:void(0)" id="J_Go" class="submit-btn submit-btn-disabled" aria-label="请注意如果没有选择宝贝，将无法结算">
                             <span>结&nbsp;算</span><b></b></a></div>
                 </div>
             </div>
         </div>
     </div>



 </div>

 </div><!--end main-content-->

</div> <!--end main-wrap-->

<span class="mytaobao-rc-bt"><span></span></span>
 </div>
 </div>
 <!-- end col-main -->

   <div class="col-sub" id="J_Col_Sub">

            <%=new msBsc.WebUi.Code.QtHtmlGet().GetCustomMenu()%>
 </div>
 </div><!-- end mytaobao-panel -->
  




            </div>
        </div>
        <!-- template -->
        <textarea id="cart_list_temp" style="display: none;">  
        {{# if(d.rows.length == 0){ }} 
     <div class="no-result-box layout-center"> 
       没有符合条件的宝贝，请尝试其他搜索条件。
       </div> 
        {{#} else {}} {{# for(var i = 0, len = d.rows.length; i < len; i++){ }} 
        
     <div class="shop-order" style="height: auto;">
         <div  class="J_Order clearfix order-body  all-select">
             <div class="J_ItemHead shop clearfix">
                 <div class="shop-info">
                         <input class="J_CheckBoxShop" id="J_CheckShop_{{d.rows[i].COMM_TENANT_ID}}" type="checkbox" name="J_CheckShop_{{d.rows[i].COMM_TENANT_ID}}"
                             value="{{d.rows[i].COMM_TENANT_ID}}" ><label for="J_CheckShop_{{d.rows[i].COMM_TENANT_ID}}" title="勾选此店铺下所有商品"></label>
                     &nbsp;&nbsp;店铺：<a href="/c_ShopView.htm?ID={{d.rows[i].COMM_TENANT_ID}}"
                         target="_blank" title="{{d.rows[i].COMM_TENANT_NME}}" class="J_MakePoint" >{{d.rows[i].COMM_TENANT_NME}}</a></div>
             </div>
             <div class="order-content">
                 <div  class="item-list">
                     <div  class="bundle  bundle-last ">
                     {{#for(var r=0,lenr=d.rows[i].rows.length;r < lenr;r ++){}}
                         <div class="goods-item">
                             <div  class="J_ItemBody item-body clearfix item-normal  first-item {{#if(d.rows[i].rows[r].IS_DEL=='1'){}} item-invalid {{#}}}  ">
                                 <ul class="item-content clearfix">
                                     <li class="td td-chk">
                                         <div class="td-inner">
                                             {{#if(d.rows[i].rows[r].IS_DEL!='1'){}}
                                                <div class="cart-checkbox cart-checkbox-checked">
                                                 <input class="J_CheckBoxItem" id="J_CheckBox_{{d.rows[i].rows[r].CART_ORDER_ID}}" type="checkbox" name="J_CheckBox_{{d.rows[i].rows[r].CART_ORDER_ID}}" order-id="{{d.rows[i].rows[r].CART_ORDER_ID}}">
                                                 <label for="J_CheckBox_{{d.rows[i].rows[r].CART_ORDER_ID}}">勾选商品</label></div>
                                             {{#}else{}}
                                                <a class="item-label label-invalid" title="商品被下架、删除、库存不足，或商家处于被监管或冻结状态" target="_blank" href="javascript:void(0);" >失效</a>
                                             {{#}}}
                                         </div>
                                     </li>
                                     <li class="td td-item">
                                         <div class="td-inner">
                                             <div class="item-pic J_ItemPic img-loaded">
                                                 <a href="/c_GoodsView.htm?ID={{d.rows[i].rows[r].GOODS_ID}}" target="_blank" class="J_MakePoint" >
                                                     <img src="{{d.rows[i].rows[r].IMG_URL}}"
                                                         class="itempic J_ItemImg"></a></div>
                                             <div class="item-info">
                                                 <div class="item-basic-info">
                                                     <a href="/c_GoodsView.htm?ID={{d.rows[i].rows[r].GOODS_ID}}" target="_blank" class="item-title J_MakePoint"
                                                         >{{d.rows[i].rows[r].GOODS_NME}}</a>
                                                 </div>
                                                 <div class="item-other-info">
                                                     <div class="promo-logos">
                                                     </div>
                                                     <div class="item-icon-list clearfix"> 
                                                     </div>
                                                 </div>
                                             </div>
                                         </div>
                                     </li>
                                     <li class="td td-info">
                                         <div class="item-props item-props-can">
                                             <p class="sku-line" tabindex="0">
                                                 {{d.rows[i].rows[r].NORMS_DESC}}</p>
                                             </div>
                                     </li>
                                     <li class="td td-price">
                                         <div class="td-inner">
                                         {{#if(d.rows[i].rows[r].GOODS_OLD_PRICE==d.rows[i].rows[r].GOODS_STRIKE_PRICE){}}
                                             <div class="item-price price-promo-">
                                                 <div class="price-content">
                                                     <div class="price-line">
                                                         <em class="J_Price price-now" tabindex="0">{{d.rows[i].rows[r].GOODS_STRIKE_PRICE}}</em></div>
                                                 </div>
                                             </div>
                                             {{#}else{}}
                                                   <div class="item-price price-promo-promo"><div class="price-content"><div class="price-line"><em class="price-original">{{d.rows[i].rows[r].GOODS_OLD_PRICE}}</em></div><div class="price-line"><em class="J_Price price-now" tabindex="0">{{d.rows[i].rows[r].GOODS_STRIKE_PRICE}}</em></div></div><div class="promo-main promo-promo"><div class="promo-content  promo-cuxiaobaoDiscount J_ItemPromotions promo-hover">卖家促销<span class="arrow"></span></div></div></div>
                                             {{#}}}
                                         </div>
                                     </li>
                                     <li class="td td-amount">
                                         <div class="td-inner">
                                             {{#if(d.rows[i].rows[r].IS_DEL!='1'){}}
                                             <div class="amount-wrapper ">
                                                 <div class="item-amount ">
                                                     <a href="javascript:void(0);" class="J_Minus ">-</a><input type="text" value="{{d.rows[i].rows[r].GOODS_QTY}}" class="text text-amount J_ItemAmount"
                                                         data-max="{{d.rows[i].rows[r].SHOP_GOODS_QTY}}" autocomplete="off" readonly="readonly"><a href="javascript:void(0);" class="J_Plus plus">+</a></div>
                                                 <div class="amount-msg J_AmountMsg">
                                                 </div>
                                             </div>
                                             {{#}else{}}
                                                <div class="amount-wrapper "><div class="item-amount ">{{d.rows[i].rows[r].GOODS_QTY}}</div></div>
                                             {{#}}}
                                         </div>
                                     </li>
                                     <li class="td td-sum">
                                         <div class="td-inner">
                                             <em tabindex="0" class="J_ItemSum number">{{d.rows[i].rows[r].SHOP_AMT}}</em><div class="J_ItemLottery">
                                             </div>
                                         </div>
                                     </li>
                                     <li class="td td-op">
                                         <div class="td-inner">
                                             <a href="javascript:void(0);" 
                                                     class="J_Del J_MakePoint" order-id="{{d.rows[i].rows[r].CART_ORDER_ID}}">删除</a></div>
                                     </li>
                                 </ul>
                             </div>
                         </div>
                     {{#}}}
                      
                     </div>
                 </div>
             </div>
         </div>
     </div>
       
        {{# }}} {{# }}}

        </textarea> 
        <%=new msBsc.WebUi.Code.QtHtmlGet().GetFloorHtml()%>
    </div>
    <!-- foot script -->
</body>
</html>
